﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

#if WINDOWS_PHONE
using Microsoft.Devices;
#endif

namespace Imaginecup.util
{
#if WINDOWS_PHONE
    public class VibrateMan
    {
        private bool m_bEnable;
        private static VibrateMan m_Vibrate = null;
        private VibrateMan()
        {
            m_bEnable = true;
        }

        public static VibrateMan GetVibrateMan()
        {
            if(m_Vibrate == null)
            {
                m_Vibrate = new VibrateMan();
            }
            return m_Vibrate;
        }

        public void SetEnable( bool enable )
        {
            m_bEnable = enable;

            if (m_bEnable)
                Start();
        }

        public void Start(TimeSpan duration)
        {
            if( m_bEnable)
                VibrateController.Default.Start(duration);//TimeSpan.FromSeconds(1));
        }

        public  void Start()
        {
            if (m_bEnable)
                VibrateController.Default.Start(TimeSpan.FromSeconds(1));
        }

        public  void Stop()
        {
            if (m_bEnable)
                VibrateController.Default.Stop();
        }


        public bool GetEnable()
        {
            return m_bEnable;
        }
    }

#endif
}
